// Copyright (C) Kumo inc. and its affiliates.
// Author: Jeff.li lijippy@163.com
// All rights reserved.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.
//
#pragma once

#include <pollux/functions/registerer.h>

namespace kumo::pollux::functions {
    namespace {
        template<template <class> typename T>
        void registerBinaryIntegral(const std::vector<std::string> &aliases) {
            register_function<T, int8_t, int8_t, int8_t>(aliases);
            register_function<T, int16_t, int16_t, int16_t>(aliases);
            register_function<T, int32_t, int32_t, int32_t>(aliases);
            register_function<T, int64_t, int64_t, int64_t>(aliases);
        }

        template<template <class> typename T>
        void registerBinaryFloatingPoint(const std::vector<std::string> &aliases) {
            register_function<T, double, double, double>(aliases);
            register_function<T, float, float, float>(aliases);
        }

        template<template <class> typename T>
        void registerBinaryNumeric(const std::vector<std::string> &aliases) {
            registerBinaryIntegral<T>(aliases);
            registerBinaryFloatingPoint<T>(aliases);
        }

        template<template <class> class T, typename TReturn>
        void registerBinaryScalar(const std::vector<std::string> &aliases) {
            register_function<T, TReturn, int8_t, int8_t>(aliases);
            register_function<T, TReturn, int16_t, int16_t>(aliases);
            register_function<T, TReturn, int32_t, int32_t>(aliases);
            register_function<T, TReturn, int64_t, int64_t>(aliases);
            register_function<T, TReturn, double, double>(aliases);
            register_function<T, TReturn, float, float>(aliases);
            register_function<T, TReturn, Varchar, Varchar>(aliases);
            register_function<T, TReturn, Varbinary, Varbinary>(aliases);
            register_function<T, TReturn, bool, bool>(aliases);
            register_function<T, TReturn, Timestamp, Timestamp>(aliases);
            register_function<T, TReturn, Date, Date>(aliases);
        }

        template<template <class> class T>
        void registerUnaryIntegral(const std::vector<std::string> &aliases) {
            register_function<T, int8_t, int8_t>(aliases);
            register_function<T, int16_t, int16_t>(aliases);
            register_function<T, int32_t, int32_t>(aliases);
            register_function<T, int64_t, int64_t>(aliases);
        }

        template<template <class> class T, typename TReturn>
        void registerUnaryIntegralWithTReturn(const std::vector<std::string> &aliases) {
            register_function<T, TReturn, int8_t>(aliases);
            register_function<T, TReturn, int16_t>(aliases);
            register_function<T, TReturn, int32_t>(aliases);
            register_function<T, TReturn, int64_t>(aliases);
        }

        template<template <class> class T>
        void registerUnaryFloatingPoint(const std::vector<std::string> &aliases) {
            register_function<T, double, double>(aliases);
            register_function<T, float, float>(aliases);
        }

        template<template <class> class T>
        void registerUnaryNumeric(const std::vector<std::string> &aliases) {
            registerUnaryIntegral<T>(aliases);
            registerUnaryFloatingPoint<T>(aliases);
        }
    } // namespace
} // namespace kumo::pollux::functions
